## 指定最低版本
cmake_minimum_required(VERSION 3.5.1)

## 指定为C99 版本
set(CMAKE_C_STANDARD 99)

## 工程名
project("tiny-modbus")

## 编译工具
# set(CMAKE_C_COMPILER "gcc")

## 设置C/C++ 编译参数
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -g3")

if(NOT DEFINED PROJECT_PATH)
    set(PROJECT_PATH ${PROJECT_SOURCE_DIR})
endif()

## 输出路径
if(NOT DEFINED OUTPUT_PATH)
    set(OUTPUT_PATH ${PROJECT_PATH}/build)
endif()
if(NOT DEFINED LIBPATH)
    set(LIBPATH ${OUTPUT_PATH}/lib)
endif()
if(NOT DEFINED EXECPATH)
    set(EXECPATH ${OUTPUT_PATH}/bin)
endif()

set(LIBRARY_OUTPUT_PATH ${LIBPATH})

add_subdirectory(${PROJECT_SOURCE_DIR}/src)
add_subdirectory(${PROJECT_SOURCE_DIR}/port/linux)

option(MODBUS_LINUX_TEST "Compile test application" OFF)

if(MODBUS_LINUX_TEST)
    add_subdirectory(${PROJECT_SOURCE_DIR}/tests/linux)
else()

endif()



